#ifndef MARKDOWN_CPP_CONFIG_H
#define MARKDOWN_CPP_CONFIG_H

#include <QtCore/QSize>
#include <QtGui/QFont>
#include <QtGui/QPalette>
#include <vector>
#include <map>
#include <iostream>
#include <boost/json.hpp>
#include <fstream>
#include "HeadFiles.h"
#include "../log/singleTo.h"
#include "../utils/utils.h"

#define CONFIG() hps::Config::GetInstance()

namespace hps {

class ButtonName {
public:
    enum Button {
        unknow = - 1,
        noteBook = 0,
        noteBookDir = 1,
        search = 2,
        tabWidgetMore = 3,
        markdownEdit = 4,
        markdownPreview = 5,
        markdownPreviewAndEdit = 6
    };
};

class FileType {
public:
    enum Type {
        unknow = -1,
        markDown = 0,
        cpp = 1,
        h = 2,
        html = 3,
        xml = 4,
        json = 5,
        pdf = 6
    };
};

class _Config {
public:
    _Config();
    ~_Config();
    QSize getIconQSize() const { return m_iconSize; }
    QSize getTabWidgetIconSize() const { return m_tabWidgetIconSize; }
    QFont getEditorFirstWordFont() const { return m_editorFirstWordFont; }
    QFont getEditorTextEditFont() const { return m_editorTextEditFont; }
    QPalette getEditorFirstWordPalette() const { return m_editorFirstWordPalette; }

    void loadDataBase();
    void reLoadDataBase();
    void addNoteBook(const std::string& bookName, std::string& bookPath);
    void setEditorTextPointSize(int size);
    void outPutJsonCfg();
    void updateDataBaseTime();
private:
    QSize m_iconSize;
    QSize m_tabWidgetIconSize;
    QFont m_editorFirstWordFont;
    QFont m_editorTextEditFont;
    QPalette m_editorFirstWordPalette;
    // 记录笔记本路径
    struct _noteBookCfg {
        std::string DataBaseName;
        std::map<std::string, std::string> NoteBookMap; // <noteBookName, Path>
        std::string CreateTime;
        std::string UpdateTime;
        std::string Description;
        int EditorTextFontSize;
    } noteBookCfg;
    boost::json::object j;
    const char *_noteBookCfgPath = "/home/hps/hps/Markdown-cpp/DataBase/noteBooks.json";

public:
    _noteBookCfg getNoteBookCfg() const { return noteBookCfg; }
};

typedef Singleton<_Config> Config;
}

#endif //MARKDOWN_CPP_CONFIG_H
